//
//  StudyReportScoreTCell.m
//  jzyParents
//
//  Created by 任辰东 on 2025/3/5.
//

#import "StudyReportScoreTCell.h"
#import "NSString+Size.h"
#import "NSString+Attributed.h"

@interface StudyReportScoreTCell ()
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@property (nonatomic, strong) UILabel *label3;
@property (nonatomic, strong) UILabel *label4;
@property (nonatomic, strong) UILabel *label5;

@property (nonatomic, strong) UIButton *scoreBtn;
@property (nonatomic, strong) UIButton *cardBtn;
@end

@implementation StudyReportScoreTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)scoreBtnAction
{
    if (self.scoreBtnBLock) {
        self.scoreBtnBLock();
    }
}

-(void)cardBtnAction
{
    if (self.cardBtnBLock) {
        self.cardBtnBLock();
    }
}

-(void)configCellWithModel:(Kaoshi_score_listItem *)model
{
    self.label1.text = model.kemu_name;
//    self.label2.text = model.score;
    
    NSString *score = [NSString stringWithFormat:@"%@",IsEmpty(model.score)?@"0":model.score];
//    NSString *all_score = [NSString stringWithFormat:@"/%@",IsEmpty(model.all_score)?@"0":model.all_score];
//    NSString *scoreStr = [NSString stringWithFormat:@"%@%@",score,all_score];
    
    self.label2.text = score;
    
//    self.label2.attributedText = [scoreStr setAttributedStringWith:scoreStr WithIndexes:all_score WithStringColor:UIColorFromHex(0x000000) WithIndexesColor:UIColorFromHex(0x999999) WithFont:UIFontSize(15)];
//    self.label3.text = model.banji_mingci;
//    self.label4.text = model.xuexiao_mingci;
//    self.label5.text = @"查看";
}

-(void)setupViews
{
//    [self.contentView addSubview:self.containerView];
    self.contentView.backgroundColor = UIColorFromHex(kColorWhite);
    [self.contentView addSubview:self.label1];
    [self.contentView addSubview:self.label2];
//    [self.contentView addSubview:self.label3];
//    [self.contentView addSubview:self.label4];
//    [self.contentView addSubview:self.label5];
    
    [self.contentView addSubview:self.scoreBtn];
    [self.contentView addSubview:self.cardBtn];
    
    [self.scoreBtn addTarget:self action:@selector(scoreBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.cardBtn addTarget:self action:@selector(cardBtnAction) forControlEvents:UIControlEventTouchUpInside];
}

-(void)setupLayout
{
    
    CGFloat width = (kScreenWidth - 15 *2) /5.0;
    [self.label1 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.contentView).offset(15);
        make.top.equalTo(self.contentView).offset(0);
        make.width.mas_equalTo(width);
        make.height.mas_equalTo(20);
        make.bottom.equalTo(self.contentView).offset(-15);
    }];
    
    [self.label2 mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.label1.mas_right).offset(10);
        make.top.equalTo(self.contentView).offset(0);
        make.width.mas_equalTo(width);
    }];
    
//    [self.label3 mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.left.equalTo(self.label2.mas_right).offset(0);
//        make.top.equalTo(self.contentView).offset(15);
//        make.width.mas_equalTo(width);
//    }];
//
//    [self.label4 mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.left.equalTo(self.label3.mas_right).offset(0);
//        make.top.equalTo(self.contentView).offset(15);
//        make.width.mas_equalTo(width);
//    }];
//
//    [self.label5 mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.left.equalTo(self.label4.mas_right).offset(0);
//        make.top.equalTo(self.contentView).offset(15);
//        make.width.mas_equalTo(width);
//    }];
    
//    CGFloat btnWidth = [@"" widthWithFont:UIFontSize(12) constrainedToHeight:20];
    
    [self.scoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {

//        make.left.equalTo(self.label2.mas_right).offset(width - 26);
        make.top.equalTo(self.contentView).offset(0);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
    }];
    
    [self.cardBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.equalTo(self.scoreBtn.mas_right).offset(15);
        make.top.equalTo(self.contentView).offset(0);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
        make.right.equalTo(self.contentView).offset(-15);
    }];
}



#pragma mark -- lazyLoad

-(UILabel *)label1
{
    if (!_label1) {
        _label1 = [UILabel new];
        _label1.text = @"题号";
        _label1.textColor = UIColorFromHex(0x666666);
        _label1.font = UIFontSize(14);
        _label1.textAlignment = NSTextAlignmentLeft;
    }
    return _label1;
}

-(UILabel *)label2
{
    if (!_label2) {
        _label2 = [UILabel new];
        _label2.text = @"题型";
        _label2.textColor = UIColorFromHex(0x000000);
        _label2.font = UIFontSize(14);
        _label2.textAlignment = NSTextAlignmentCenter;
    }
    return _label2;
}

-(UILabel *)label3
{
    if (!_label3) {
        _label3 = [UILabel new];
        _label3.text = @"答案";
        _label3.textColor = UIColorFromHex(0x000000);
        _label3.font = UIFontSize(15);
        _label3.textAlignment = NSTextAlignmentCenter;
    }
    return _label3;
}


-(UILabel *)label4
{
    if (!_label4) {
        _label4 = [UILabel new];
        _label4.text = @"得分/满分";
        _label4.textColor = UIColorFromHex(0x000000);
        _label4.font = UIFontSize(15);
        _label4.textAlignment = NSTextAlignmentCenter;
    }
    return _label4;
}

-(UILabel *)label5
{
    if (!_label5) {
        _label5 = [UILabel new];
        _label5.text = @"更多";
        _label5.textColor = UIColorFromHex(0x000000);
        _label5.font = UIFontSize(15);
        _label5.textAlignment = NSTextAlignmentRight;
    }
    return _label5;
}

-(UIButton *)scoreBtn
{
    if (!_scoreBtn) {
        _scoreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_scoreBtn setBackgroundColor:UIColorFromHex(kColorWhite)];
        [_scoreBtn setTitle:@"小题得分" forState:UIControlStateNormal];
        [_scoreBtn setTitleColor:UIColorFromHex(kColorMain) forState:UIControlStateNormal];
        _scoreBtn.titleLabel.font = UIFontSize(12);
        _scoreBtn.layer.cornerRadius = 5;
        _scoreBtn.layer.masksToBounds = YES;
        _scoreBtn.layer.borderWidth = kOnePixel;
        _scoreBtn.layer.borderColor = UIColorFromHex(kColorMain).CGColor;
    }
    return _scoreBtn;
}

-(UIButton *)cardBtn
{
    if (!_cardBtn) {
        _cardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cardBtn setBackgroundColor:UIColorFromHex(kColorMain)];
        [_cardBtn setTitle:@"答题卡" forState:UIControlStateNormal];
        [_cardBtn setTitleColor:UIColorFromHex(kColorWhite) forState:UIControlStateNormal];
        _cardBtn.titleLabel.font = UIFontSize(12);
        _cardBtn.layer.cornerRadius = 5;
        _cardBtn.layer.masksToBounds = YES;
//        _cardBtn.layer.borderWidth = kOnePixel;
//        _cardBtn.layer.borderColor = UIColorFromHex(kColorMain).CGColor;
    }
    return _cardBtn;
}



@end
